package com.ruoyi.web.controller.examine;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.examine.domain.TbClassCheck;
import com.ruoyi.examine.service.ITbClassCheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 班级检查Controller
 *
 * @author ruoyi
 * @date 2023-12-28
 */
@RestController
@RequestMapping("/examine/check")
public class TbClassCheckController extends BaseController
{
    @Autowired
    private ITbClassCheckService tbClassCheckService;

    /**
     * 查询班级检查列表
     */
    @PreAuthorize("@ss.hasPermi('examine:check:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbClassCheck tbClassCheck)
    {
        startPage();
        List<TbClassCheck> list = tbClassCheckService.selectTbClassCheckList(tbClassCheck);
        return getDataTable(list);
    }

    /**
     * 导出班级检查列表
     */
    @PreAuthorize("@ss.hasPermi('examine:check:export')")
    @Log(title = "班级检查", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbClassCheck tbClassCheck)
    {
        List<TbClassCheck> list = tbClassCheckService.selectTbClassCheckList(tbClassCheck);
        ExcelUtil<TbClassCheck> util = new ExcelUtil<TbClassCheck>(TbClassCheck.class);
        util.exportExcel(response, list, "班级检查数据");
    }

    /**
     * 获取班级检查详细信息
     */
    @PreAuthorize("@ss.hasPermi('examine:check:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tbClassCheckService.selectTbClassCheckById(id));
    }

    /**
     * 新增班级检查
     */
    @PreAuthorize("@ss.hasPermi('examine:check:add')")
    @Log(title = "班级检查", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbClassCheck tbClassCheck)
    {
        return toAjax(tbClassCheckService.insertTbClassCheck(tbClassCheck));
    }

    /**
     * 修改班级检查
     */
    @PreAuthorize("@ss.hasPermi('examine:check:edit')")
    @Log(title = "班级检查", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbClassCheck tbClassCheck)
    {
        return toAjax(tbClassCheckService.updateTbClassCheck(tbClassCheck));
    }

    /**
     * 删除班级检查
     */
    @PreAuthorize("@ss.hasPermi('examine:check:remove')")
    @Log(title = "班级检查", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tbClassCheckService.deleteTbClassCheckByIds(ids));
    }
}
